package com.itheima.mMothodDemo;

import java.util.Scanner;

/*
     定义一个方法接收三个整数变量,并从大到小依此打印
 */
public class Work01 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //1.建立录入
        System.out.println("请输入第一个整数:");
        int num1 = sc.nextInt();
        System.out.println("请输入第二个整数:");
        int num2 = sc.nextInt();
        System.out.println("请输入第三个整数:");
        int num3 = sc.nextInt();
        print(num1,num2,num3);
    }

    /*
          功能:将数据按从大到小排序并打印     ----- print()
          条件:键入三个整数                   ----- int num1,int num2,int num3
          结果:打印                           ----- void
     */
    public static void print(int num1, int num2, int num3) {
        int[] arr = new int[3];
        arr[0] = num1 > num2 ? num1 : num2;
        arr[0] = arr[0] > num3 ? arr[0] : num3;
        arr[2] = num1 < num2 ? num1 : num2;
        arr[2] = arr[2] < num3 ? arr[2] : num3;
        arr[1] = num1 + num2 + num3 - arr[0] - arr[2];
        System.out.print("从大到小的顺序是:");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }
}
